﻿using System;
using System.Linq.Expressions;
using Domain.Core.Specification;
using Domain.MainModule.Entities;

namespace Domain.MainModule.Addresses
{
    public class AddressIdSpecification : Specification<Address>
    {
        #region public properties

        public Guid AddressId
        {
            get;
            set;
        }

        #endregion

        #region constructor

        public AddressIdSpecification(Guid addressId)
        {
            this.AddressId = addressId;
        }

        #endregion

        #region public methods

        public override Expression<Func<Address, bool>> SatisfiedBy()
        {
            Specification<Address> spec = new TrueSpecification<Address>();
            spec &= new DirectSpecification<Address>(c => c.AddressId == this.AddressId);

            return spec.SatisfiedBy();
        }

        #endregion
    }
}
